.class public Lcom/netease/newsreader/service/ClearCacheService;
.super Landroid/app/Service;
.source "ClearCacheService.java"


# instance fields
.field private db:Landroid/database/sqlite/SQLiteDatabase;


# direct methods
.method public constructor <init>()V
    .locals 0

    .prologue
    .line 19
    invoke-direct {p0}, Landroid/app/Service;-><init>()V

    return-void
.end method


# virtual methods
.method public onBind(Landroid/content/Intent;)Landroid/os/IBinder;
    .locals 1
    .parameter "arg0"

    .prologue
    .line 27
    const/4 v0, 0x0

    return-object v0
.end method

.method public onCreate()V
    .locals 12

    .prologue
    .line 33
    invoke-super {p0}, Landroid/app/Service;->onCreate()V

    .line 35
    invoke-virtual {p0}, Lcom/netease/newsreader/service/ClearCacheService;->getApplicationContext()Landroid/content/Context;

    move-result-object v0

    check-cast v0, Lcom/netease/newsreader/activity/MyApplication;

    .line 36
    .local v0, app:Lcom/netease/newsreader/activity/MyApplication;
    invoke-virtual {v0}, Lcom/netease/newsreader/activity/MyApplication;->getSQLiteDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v7

    iput-object v7, p0, Lcom/netease/newsreader/service/ClearCacheService;->db:Landroid/database/sqlite/SQLiteDatabase;

    .line 38
    new-instance v6, Ljava/text/SimpleDateFormat;

    const-string v7, "yyyy-MM-dd HH:mm:ss"

    invoke-direct {v6, v7}, Ljava/text/SimpleDateFormat;-><init>(Ljava/lang/String;)V

    .line 39
    .local v6, sDateFormat:Ljava/text/SimpleDateFormat;
    new-instance v7, Ljava/util/Date;

    .line 40
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v8

    sget-wide v10, Lcom/netease/newsreader/bean/DetailPageBean;->ExpiredDuration:J

    sub-long/2addr v8, v10

    invoke-direct {v7, v8, v9}, Ljava/util/Date;-><init>(J)V

    .line 39
    invoke-virtual {v6, v7}, Ljava/text/SimpleDateFormat;->format(Ljava/util/Date;)Ljava/lang/String;

    move-result-object v1

    .line 45
    .local v1, date:Ljava/lang/String;
    :try_start_0
    iget-object v7, p0, Lcom/netease/newsreader/service/ClearCacheService;->db:Landroid/database/sqlite/SQLiteDatabase;

    new-instance v8, Ljava/lang/StringBuilder;

    const-string v9, "delete from news_list where news_ptime< \'"

    invoke-direct {v8, v9}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    .line 46
    invoke-virtual {v8, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    const-string v9, "\'"

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v8

    .line 45
    invoke-virtual {v7, v8}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V

    .line 47
    iget-object v7, p0, Lcom/netease/newsreader/service/ClearCacheService;->db:Landroid/database/sqlite/SQLiteDatabase;

    new-instance v8, Ljava/lang/StringBuilder;

    const-string v9, "delete from comments_list where comments_ptime< \'"

    invoke-direct {v8, v9}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    .line 48
    invoke-virtual {v8, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    const-string v9, "\' and "

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    .line 49
    const-string v9, "comments_col_id"

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    const-string v9, "= \'top\'"

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v8

    .line 47
    invoke-virtual {v7, v8}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V

    .line 50
    iget-object v7, p0, Lcom/netease/newsreader/service/ClearCacheService;->db:Landroid/database/sqlite/SQLiteDatabase;

    new-instance v8, Ljava/lang/StringBuilder;

    const-string v9, "delete from photo_list where photo_date< \'"

    invoke-direct {v8, v9}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    .line 51
    invoke-virtual {v8, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    const-string v9, "\'"

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v8

    .line 50
    invoke-virtual {v7, v8}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V
    :try_end_0
    .catch Landroid/database/SQLException; {:try_start_0 .. :try_end_0} :catch_0

    .line 57
    :goto_0
    new-instance v3, Ljava/io/File;

    sget-object v7, Lcom/netease/newsreader/util/FileUtils;->DetailPageTempDir:Ljava/lang/String;

    invoke-direct {v3, v7}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 58
    .local v3, f:Ljava/io/File;
    new-instance v4, Ljava/io/File;

    sget-object v7, Lcom/netease/newsreader/util/PicUtil;->phototempDir:Ljava/lang/String;

    invoke-direct {v4, v7}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 59
    .local v4, f2:Ljava/io/File;
    new-instance v5, Ljava/io/File;

    sget-object v7, Lcom/netease/newsreader/util/FileUtils;->FileTempDir:Ljava/lang/String;

    invoke-direct {v5, v7}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 60
    .local v5, f3:Ljava/io/File;
    sget-wide v7, Lcom/netease/newsreader/bean/DetailPageBean;->ExpiredDuration:J

    invoke-static {v3, v7, v8}, Lcom/netease/newsreader/util/FileUtils;->autoDeleteCacheFile(Ljava/io/File;J)Z

    .line 61
    sget-wide v7, Lcom/netease/newsreader/bean/DetailPageBean;->ExpiredDuration:J

    invoke-static {v4, v7, v8}, Lcom/netease/newsreader/util/FileUtils;->autoDeleteCacheFile(Ljava/io/File;J)Z

    .line 62
    sget-wide v7, Lcom/netease/newsreader/bean/DetailPageBean;->ExpiredDuration:J

    invoke-static {v5, v7, v8}, Lcom/netease/newsreader/util/FileUtils;->autoDeleteCacheFile(Ljava/io/File;J)Z

    .line 64
    invoke-virtual {p0}, Lcom/netease/newsreader/service/ClearCacheService;->stopSelf()V

    .line 65
    return-void

    .line 53
    .end local v3           #f:Ljava/io/File;
    .end local v4           #f2:Ljava/io/File;
    .end local v5           #f3:Ljava/io/File;
    :catch_0
    move-exception v2

    .line 55
    .local v2, e:Landroid/database/SQLException;
    invoke-virtual {v2}, Landroid/database/SQLException;->printStackTrace()V

    goto :goto_0
.end method
